package priv.pront.code.lanqiao.team.comp.mati_2;

import java.util.Scanner;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-11-02 22:41
 */
public class P1116_车厢重组 {

    static int n, ans;
    static int[] a;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; ) {
            while (i + 1 == a[i]) {
                if (i == n - 1) break;
                i++;
            }
            if (i == n - 1) break;
            int idx = i;
            while (i + 1 != a[i]) {
                if (idx + 1 == a[idx]) break;
                swap(idx, idx + 1);
                ans++;
                idx++;
            }
        }
        System.out.println(ans);
    }

    private static void swap(int i, int j) {
        int temp = a[j];
        a[j] = a[i];
        a[i] = temp;
    }
}
